package org.loofer.uiframework.navigator;

import android.os.Bundle;
import org.loofer.ext.component.logger.Logger;
import java.util.Map;

public class NavigatorParams {
    private static final String TAG = "NavigatorParams";
    private Bundle mBundle;
    private Map<String, String> mOpenParams;
    private NavigatorOptions mURLNavigatorOptions;

    public NavigatorOptions getOptions() {
        return this.mURLNavigatorOptions;
    }

    public void setOptions(NavigatorOptions URLNavigatorOptions) {
        this.mURLNavigatorOptions = URLNavigatorOptions;
    }

    public Map<String, String> getParams() {
        return this.mOpenParams;
    }

    public void setParams(Map<String, String> openParams) {
        this.mOpenParams = openParams;
    }

    public Bundle getBundle() {
        return this.mBundle;
    }

    public void setBundle(Bundle bundle) {
        this.mBundle = bundle;
    }

    public String getParamString(String key, String defaultValue) {
        if (this.mBundle == null || !this.mBundle.containsKey(key)) {
            return (this.mOpenParams == null || !this.mOpenParams.containsKey(key)) ? defaultValue : (String) this.mOpenParams.get(key);
        } else {
            return this.mBundle.getString(key, defaultValue);
        }
    }

    public boolean getParamBoolean(String key, boolean defaultValue) {
        if (this.mBundle != null && this.mBundle.containsKey(key)) {
            return this.mBundle.getBoolean(key, defaultValue);
        }
        if (this.mOpenParams == null || !this.mOpenParams.containsKey(key)) {
            return defaultValue;
        }
        try {
            return Boolean.parseBoolean((String) this.mOpenParams.get(key));
        } catch (Throwable e) {
            Logger.w(TAG, e);
            return defaultValue;
        }
    }

    public short getParamShort(String key, short defaultValue) {
        if (this.mBundle != null && this.mBundle.containsKey(key)) {
            return this.mBundle.getShort(key, defaultValue);
        }
        if (this.mOpenParams == null || !this.mOpenParams.containsKey(key)) {
            return defaultValue;
        }
        try {
            return Short.parseShort((String) this.mOpenParams.get(key));
        } catch (Throwable e) {
            Logger.w(TAG, e);
            return defaultValue;
        }
    }

    public int getParamInt(String key, int defaultValue) {
        if (this.mBundle != null && this.mBundle.containsKey(key)) {
            return this.mBundle.getInt(key, defaultValue);
        }
        if (this.mOpenParams == null || !this.mOpenParams.containsKey(key)) {
            return defaultValue;
        }
        try {
            return Integer.parseInt((String) this.mOpenParams.get(key));
        } catch (Throwable e) {
            Logger.w(TAG, e);
            return defaultValue;
        }
    }

    public long getParamLong(String key, long defaultValue) {
        if (this.mBundle != null && this.mBundle.containsKey(key)) {
            return this.mBundle.getLong(key, defaultValue);
        }
        if (this.mOpenParams == null || !this.mOpenParams.containsKey(key)) {
            return defaultValue;
        }
        try {
            return Long.parseLong((String) this.mOpenParams.get(key));
        } catch (Throwable e) {
            Logger.w(TAG, e);
            return defaultValue;
        }
    }

    public float getParamFloat(String key, float defaultValue) {
        if (this.mBundle != null && this.mBundle.containsKey(key)) {
            return this.mBundle.getFloat(key, defaultValue);
        }
        if (this.mOpenParams == null || !this.mOpenParams.containsKey(key)) {
            return defaultValue;
        }
        try {
            return Float.parseFloat((String) this.mOpenParams.get(key));
        } catch (Throwable e) {
            Logger.w(TAG, e);
            return defaultValue;
        }
    }

    public double getParamDouble(String key, double defaultValue) {
        if (this.mBundle != null && this.mBundle.containsKey(key)) {
            return this.mBundle.getDouble(key, defaultValue);
        }
        if (this.mOpenParams == null || !this.mOpenParams.containsKey(key)) {
            return defaultValue;
        }
        try {
            return Double.parseDouble((String) this.mOpenParams.get(key));
        } catch (Throwable e) {
            Logger.w(TAG, e);
            return defaultValue;
        }
    }
}
